#include <iostream>
using namespace std;
#include <string>

//统计每个月兔子的总数
//https://www.nowcoder.com/questionTerminal/1221ec77125d4370833fd3ad5ba72395?commentTags=Java
//int main() {
//    int num = 1;
//    while (cin >> num)
//    {
//        int n1 = 1, n2 = 1;
//        if (num > 2)
//        {
//            for (int i = 2; i < num; ++i)
//            {
//                int sum = n1 + n2;
//                n1 = n2;
//                n2 = sum;
//            }
//        }
//        cout << n2 << endl;
//    }
//}

//字符串通配符 - 算法学习
// https://www.nowcoder.com/questionTerminal/43072d50a6eb44d2a6c816a283b02036?orderByHotValue=1&mutiTagIds=235_645&page=8&onlyReference=false
bool iscatch(const string& str, const string& mate)
{
	int strl = str.size() - 1;
	int matel = mate.size() - 1;

	while (matel >= 0)
	{
		if ((strl >= 0 && matel >= 0) && ((str[strl] == mate[matel]) || (str[strl] == '?'))) { --strl; --matel; }
		else if (strl >= 0 && str[strl] == '*')
		{
			if (strl == 0) { return true; } //原串跑完了，首位剩下一个*，那么前面的所有串都能匹配上
			else if(matel == 0) //匹配串跑完了
			{
				//检查原串剩下的是否都是通配符，如果是则返回true
				for (int i = strl; i >= 0; --i)
				{
					if (str[i] != '*' && str[i] != '?')
					{
						return false;
					}
				}
				return true;
			}

			if (strl > matel) //字符串在比对串前面，需要不断比对
			{
				if ((strl - 1 >= 0) && (str[strl - 1] == mate[matel - 1]))
				{
					--matel;
				}
				--strl;
			}
			else if (strl == matel)
			{
				if (
					(strl > 0 && matel > 0)
					&& (str[strl - 1] == mate[matel - 1]) //匹配0个
					|| (str[strl - 1] == '*') //前面一个还是通配符*
					|| (str[strl - 1] == '?')
					)
				{
					--strl; --matel;
				}
				else
				{
					--matel;
				}
			}
			else
			{
				--matel;
			}
		}
		else return false;
	}
	return true;
}

bool isSame(char c)
{
	return (c >= '0' && c <= '9')
		|| (c >= 'a' && c <= 'z')
		|| (c >= 'A' && c <= 'Z')
		|| (c == '*')
		|| (c == '?')
		|| (c == '.');
}

int main()
{
	string str, mate;
	while (cin >> str >> mate)
	{
		int flag = 0;
		for (auto& c : str)
		{
			if (!isSame(c)) { cout << "false" << endl; flag = 1; break; }
			if (c >= 'A' && c <= 'Z') { c += 32; }
		}
		for (auto& c : mate)
		{
			if (!isSame(c)) { cout << "false" << endl; flag = 1; break; }
			if (c >= 'A' && c <= 'Z') { c += 32; }
		}
		if (flag) { continue; }

		if (iscatch(str, mate)) cout << "true" << endl;
		else cout << "false" << endl;
	}
	return 0;
}


//简化解法 - 存在部分bug
bool iscatch(const string& str, const string& mate)
{
	int strl = str.size()-1; //左右区间
	int matel = mate.size()-1; 

	while (matel >= 0) //匹配串走完了就匹配完成了
	{
		if (str[strl] == mate[matel] || str[strl] == '?')
		{
			--strl;
			--matel;
		}
		else if (str[strl] == '*')
		{
			if ((strl - 1 >= 0) && (str[strl - 1] == mate[matel]))
			{
				--strl;
			}
			else if ((strl - 1 >= 0 && matel - 1 >= 0) && (str[strl - 1] == mate[matel - 1]))
			{
				--strl;
				--matel;
			}
			else if (strl - 1 >= 0 && (str[strl - 1] == '*' || str[strl - 1] == '?')) //如果下一个还是通配符则同时走一步
			{
				--strl;
				--matel;
			}
			else
			{
				--matel;
			}
		}
		else
		{
			return false;
		}
	}
	return true;
}
bool isSame(char c) {
    return (c >= '0' && c <= '9')
           || (c >= 'a' && c <= 'z')
           || (c >= 'A' && c <= 'Z')
           || (c == '*')
           || (c == '?')
           || (c == '.');
}

int main() {
    string str, mate;
    while (cin >> str >> mate) {
        int flag = 0;
        for (auto& c : str) {
            if (!isSame(c)) {
                cout << "false" << endl;
                flag = 1;
                break;
            }
            if (c >= 'A' && c <= 'Z') {
                c += 32;
            }
        }
        for (auto& c : mate) {
            if (!isSame(c)) {
                cout << "false" << endl;
                flag = 1;
                break;
            }
            if (c >= 'A' && c <= 'Z') {
                c += 32;
            }
        }
        if (flag) {
            continue;
        }

        if (iscatch(str, mate)) cout << "true" << endl;
        else cout << "false" << endl;
    }
    return 0;
}